package top.littleze.aiattendance.utils.page;

/**
 * @Author ZhaoGengze
 * @Date 2021/7/3 13:54
 */

import java.util.List;

public class PagedReply<T> extends Reply<PageResult<T>> {
    public PagedReply() {
    }

    public PagedReply(PageResult<T> data) {
        this.setSuccess(true);
        this.setCode(0);
        this.setMsg("");
        this.setData(data);
    }

    public PagedReply(int index, int pageSize, long totalCount, List<T> data) {
        this.setSuccess(true);
        this.setCode(0);
        this.setMsg("");
        this.setData(new PageResult(index, pageSize, totalCount, data));
    }

    public static <T> PagedReply<T> success(int index, int pageSize, long totalCount, List<T> data) {
        return new PagedReply(index, pageSize, totalCount, data);
    }

    public static <T> PagedReply<T> pagedFailure(String message) {
        PagedReply reply = new PagedReply();
        reply.setSuccess(false);
        reply.setMsg(message);
        return reply;
    }
}
